import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import com.uade.facade.Facade;

public class Main {
	public static void main(String[] args) throws NamingException {
		
		// Test Jboos
		Facade facade = getRemoteFacade();
		

	}

	/*
	 * (non-Java-doc)
	 * 
	 * @see java.lang.Object#Object()
	 */
	public Main() {
		super();
	}

	private static Facade getRemoteFacade() throws NamingException{
		final String appName = "PortalBackendEarEJB";
		final String moduleName = "PortalBackendEarEJB";
		final String sessionBeanName = "FacadeBean";
		final String viewClassName = Facade.class.getName();
		Properties jndiProps = new Properties();
		jndiProps.put(Context.INITIAL_CONTEXT_FACTORY,
				"org.jboss.naming.remote.client.InitialContextFactory");
		jndiProps.put(Context.PROVIDER_URL, "remote://127.0.0.1:4447");
		// username
		jndiProps.put(Context.SECURITY_PRINCIPAL, "test");
		// password
		jndiProps.put(Context.SECURITY_CREDENTIALS, "test123");
		// This is an important property to set if you want to do EJB
		// invocations via the remote naming project
		jndiProps.put("jboss.naming.client.ejb.context", true);
		// create context passing these properties
		Context context = new InitialContext(jndiProps);

		// lookup the bean facade
		Facade facade = (Facade) context.lookup(appName + "/" + moduleName
				+ "/" + sessionBeanName + "!" + viewClassName);
		
		return facade;
	}
}